package es.kivitel.android.sms.gui;
import java.util.ArrayList;
import java.util.HashMap;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.SimpleAdapter;
import es.kivitel.android.sms.R;

public class ConfigActivity extends ListActivity{
	ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
	private static final int ADD_ITEM_ID = 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle){
       super.onCreate(icicle);
       setContentView(R.layout.configuration);
       HashMap<String,String> item = new HashMap<String,String>();
       item.put( "line1","Gmail user data");
	   list.add( item );
       SimpleAdapter notes = new SimpleAdapter( 
				this, 
				list,
				R.layout.config_row,
				new String[] { "line1" },
				new int[] { R.id.text1}  );
       setListAdapter( notes );
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
      boolean result = super.onCreateOptionsMenu(menu);
      return result;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
		addItem();
        return super.onOptionsItemSelected(item);
    }

	private void addItem() {
	  long ts = System.currentTimeMillis();
	  HashMap<String,String> item = new HashMap<String,String>();
	  item.put( "line1",Long.toString( ts ) );
	  list.add( item );
      SimpleAdapter notes = new SimpleAdapter( 
				this, 
				list,
				R.layout.config_row,
				new String[] { "line1" },
				new int[] { R.id.text1}  );
       setListAdapter( notes );
	}
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	super.onActivityResult(requestCode, resultCode, data);
    	Bundle extras = data.getExtras();
    	if(extras.getInt("Close") == 1)
    		finish();  	
    }
	
}
